
var layer = layui.layer //弹层
    ,table = layui.table //表格
    ,form = layui.form,$ = layui.jquery,laydate = layui.laydate;
lay('.starttime').each(function(){
    laydate.render({
        elem: this
    });
});

//标签 判断是否有此角色
let warehouseLabel = getAllRolesByCurr("WarehouseManagementPrice");

table.render({
    elem: '#productquery',
    url: 'stock/getStockProductByPage',
    cols: [[
        {field: 'lotNo', width: 120, title: '批次号', sort: true},
        {field: 'productCode', width: 120, title: '产品编码', sort: true},
        {field: 'specificationCode', width: 120, title: '规格编码', sort: true},
        {field: 'specificationExplanation', width: 120, title: '规格说明', sort: true},
        {field: 'warehouse', width: 120, title: '仓库名称', sort: true},
        {field: 'contractNo', width: 120, title: '合同号', sort: true},
        {field: 'contractTypeStr', width: 120, title: '合同类型', sort: true},
        {field: 'realQuantity', width: 120, title: '实际数量', sort: true},
        {field: 'realAvailableQuantity', width: 160, title: '实际可用数量', sort: true},
        {field: 'canApplyQuantity', width: 140, title: '可申请数量',sort: true},
        {field: 'outWarehouseApply', width: 160, title: '出库申请数量',sort: true},
        {field: 'supplierName', width: 140, title: '供应商名称',sort: true},
        {field: 'clientProductNo', width: 120, title: '客户货号', sort: true},
        {field: 'productCname', width: 160, title: '产品中文名称', sort: true},
        {field: 'productEname', width: 160, title: '产品英文名称', sort: true},
        {field: 'color', width: 120, title: '颜色', sort: true},
        {field: 'costAmount', width: 120, title: '成本金额', sort: true},
        {field: 'productUnitPrice', width: 120, title: '成本单价', sort: true},
        {field: 'memo', title: '备注',width: 80, sort: true},
        {field: 'inStoreDate', width: 120, title: '入库日期', sort: true},
        {field: 'shareCostPrice', width: 160, title: '分摊费用单价', sort: true},
        {field: 'purchaseNo', width: 120, title: '采购单号', sort: true},
        {field: 'trayNumber', width: 120, title: '托盘入数', sort: true},
        {field: 'totalTray', width: 120, title: '总托盘', sort: true},
    ]]
    ,id: 'productquerytableid'
    ,height: $(document).height() - $('#productquery').offset().top - 50
    ,page: true
    ,parseData: function(res){
        return {
            "code": res.status,
            "count": res.total,
            "data": res.data
        };
    }
    ,done: function (res, curr, count) {
    if(warehouseLabel){
        //标签:控制"成本金额"、"成本单价"、"分摊费用单价"
        //成本金额
        $("[data-field='costAmount']").css("display", "none");
        //成本单价
        $("[data-field='productUnitPrice']").css("display", "none");
        //分摊费用单价
        $("[data-field='shareCostPrice']").css("display", "none");
    }
}
});
form.on('submit(submitform)', function(data){
    table.reload('productquerytableid', {
        page: {
            limit:10,
            curr: 1 //重新从第 1 页开始
        }
        ,where: data.field
    }, 'data');
    return false;
});